package cc.telecomdigital.tdstock.Services;

//Using a customized Text List
//Consider adapter is unique of this use
//Storage class for Subscription
public class LS_SubscriptionItem
{	
	private String			adapterName;

	//List of the item id
	private LSStringList	subScribeItem;
	//List of the request, schema
	private LSStringList	subScribeSchema;
	private boolean		isTableRequest;
	//Currently not support
	private boolean		runAsSuspend;

	public LS_SubscriptionItem(String iAdpaterName)
	{
		adapterName = iAdpaterName;
		isTableRequest = false;
		runAsSuspend = false;
		subScribeItem = new LSStringList();
		subScribeSchema = new LSStringList();
	}

	@Override
	public String toString()
	{
		String retString;

		retString = adapterName + ", Item: " + subScribeItem.toString()
				+ ", Schema:" + subScribeSchema.toString();

		return retString;
	}

	public boolean IsTableRequest()
	{
		return isTableRequest;
	}

	public void SetTableRequest(boolean iEnable)
	{
		isTableRequest = true;
	}

	public boolean IsBackgroundRunnable()
	{
		return runAsSuspend;
	}

	public void SetRunBackgroundEnable(boolean iEnable)
	{
		runAsSuspend = iEnable;
	}

	public LS_SubscriptionItem(LS_SubscriptionItem iSubItem)
	{
		adapterName = iSubItem.adapterName;
		isTableRequest = iSubItem.isTableRequest;
		runAsSuspend = iSubItem.runAsSuspend;
		subScribeItem = new LSStringList(iSubItem.subScribeItem);
		subScribeSchema = new LSStringList(iSubItem.subScribeSchema);
	}

	public LSStringList GetSubscribeItems()
	{
		return subScribeItem;
	}

	//Item Id
	public void SetSubscribeItem(LSStringList iSubscribeItemList)
	{
		subScribeItem.ReplaceList(iSubscribeItemList);
	}

	//Replace the whole list
	public void SetSubscribeItem(String[] iSubscribleItemArray)
	{
		subScribeItem.ReplaceList(iSubscribleItemArray);
	}
	
	public boolean AddSubscribeItem(String iSubscribeItem)
	{
		return subScribeItem.Add(iSubscribeItem);
	}

	public boolean RemoveSubscribleItem(String iSubscribeItem)
	{
		return subScribeItem.Remove(iSubscribeItem);
	}

	//Item schema
	public LSStringList GetSubscribeSchema()
	{
		return subScribeSchema;
	}

	public void SetSubscribeSchema(LSStringList iSubscribeSchemaList)
	{
		subScribeSchema.ReplaceList(iSubscribeSchemaList);
	}

	public void SetSubscribeSchema(String[] iSubscribeSchemaArray)
	{
		subScribeSchema.ReplaceList(iSubscribeSchemaArray);
	}	
	
	public boolean AddSubscribeSchema(String iSubscribeSchema)
	{
		return subScribeSchema.Add(iSubscribeSchema);
	}

	public boolean RemoveSubscribeSchema(String iSubscribeSchema)
	{
		return subScribeSchema.Remove(iSubscribeSchema);
	}

	public String GetAdapter()
	{
		return adapterName;
	}

	public void ClearInfo()
	{
		adapterName = null;
		subScribeItem.Clear();
		subScribeSchema.Clear();
	}
}
